/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * Description: Hmfs-tools compare data
 */

#include "compare.h"

#include <memory>
#include <cinttypes>
#include <cmath>
#include <string>
#include <sys/types.h>

#include "compare_check_point.h"
#include "compare_main_area.h"
#include "compare_nat.h"
#include "compare_sit.h"
#include "compare_ssa.h"
#include "compare_super_block.h"
#include "hmfs_log.h"
#include "hmfs_utils.h"
#include "securec.h"

namespace OHOS {
namespace Hmfs {
int32_t FsResultCompare(const std::string &src, const std::string &dst)
{
    OHOS::Hmfs::CompareCmdParser tmp;
    FsData srcInfo(src);
    FsData dstInfo(dst);

    HMFS_INFO("Compare %s to %s.", src.c_str(), dst.c_str());

    if (CompareSuperBlockArea(srcInfo, dstInfo)) {
        return -1;
    }

    CompareCheckPoint cp(srcInfo, dstInfo);
    if (cp.CompareCheckPointBinary()) {
        return -1;
    }

    CompareSit sit(srcInfo, dstInfo);
    if (sit.CompareSitArea()) {
        return -1;
    }

    CompareNat nat(srcInfo, dstInfo);
    if (nat.CompareNatArea()) {
        return -1;
    }

    CompareSsa ssa(srcInfo, dstInfo);
    if (ssa.CompareSsaArea()) {
        return -1;
    }

    CompareMainArea mainArea(srcInfo, dstInfo);
    if (mainArea.CompareMainAreaBinary()) {
        return -1;
    }

    HMFS_INFO("Compare OK.");
    return 0;
}
} // namespace Hmfs
} // namespace OHOS
